const express = require('express');
const router = express.Router();
const categoryController = require('../controllers/categoryController');
const { authMiddleware } = require('../middleware/auth');

// 获取所有分类
router.get('/', categoryController.getAllCategories);

// 获取单个分类
router.get('/:id', categoryController.getCategoryById);

// 创建分类 - 需要认证
router.post('/', authMiddleware, categoryController.createCategory);

// 更新分类 - 需要认证
router.put('/:id', authMiddleware, categoryController.updateCategory);

// 删除分类 - 需要认证
router.delete('/:id', authMiddleware, categoryController.deleteCategory);

module.exports = router; 